<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<style>
    .table-border tbody tr td{
        border-top: 1px solid black;
    }
</style>
<section class="content-header">
    <h1>
        合同审核
    </h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>项目编号</label>
                                    <input type="text" name="contName" class="form-control" placeholder="项目编号" >
                                </div>
                                <!--<div class="form-group" style="margin-right: 10px;">-->
                                    <!--<label>买方合同编号</label>-->
                                    <!--<input type="text" name="buyCode" class="form-control" placeholder="买方合同编号">-->
                                <!--</div>-->
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>卖方合同编号</label>
                                    <input type="text" name="sellCode" class="form-control" placeholder="卖方合同编号">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>标的物</label>
                                    <input type="text" name="contAddress" class="form-control" placeholder="标的物" >
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>登记人</label>
                                    <input type="text" name="createUser" class="form-control" placeholder="登记人" >
                                </div>

                                <div class="form-group" style="margin-right: 10px;margin-top: 5px;">
                                <label>审核状态</label>
                                <select name="appStatus" class="form-control" style="width:200px;">
                                <option  selected="selected" value="1">未审核</option>
                                <option  value="2">已审核</option>
                                    <option value="0" >全部</option>
                                </select>
                                </div>

                                <button type="button" class="btn btn-success" id="btn-search" style="margin-top: 5px;">
                                    <!--<i class="fa fa-search"></i>-->
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table" class="table-border" style="table-layout: fixed;word-break:break-all; word-wrap:break-word;"></table>
                </div>
            </div>
        </div>
    </div>
</section>

<div th:include="include :: footer">
</div>
<script th:inline="javascript">
    /** 加载用户表格 */
    table = js.table.init({
        url: ctx + "contractManage/unAppContractList",
        showColumns: true,
        showExport: true,
        pageSize:100,
        columns: [
            {
                title: '序号', field: 'id', width: '50',
                formatter: function (value, row, index, field) {
                    var pageSize = table.bootstrapTable('getOptions').pageSize;
                    var pageNumber = table.bootstrapTable('getOptions').pageNumber;
                    return pageSize * (pageNumber - 1) + index + 1;
                }
            },
            { title: "项目编号", field: 'contName'},
            { title: "包含项目", field: 'projectName'},
            { title: "卖方合同编号", field: 'sellCode'},
            // { title: "买方合同编号", field: 'buyCode'},
            { title: "标的物", field: 'contAddress'},
            { title: "买方", field: 'totalMethod'},
            { title: "类别", field: 'contType'},
            { title: "登记类型", field: 'parentId',
                formatter: function (value, row, index) {
                    if(value==0){
                        return "";
                    }else{
                        return "<span class=\"label  badge  label-maroon bg-maroon\">增补合同</span>";
                    }
                }
            },
            { title: "合同登记人", field: 'createUser'},
            { title: "创建时间", field: 'contYear'},
            { title: "审批状态", field: 'appStatus',
                formatter: function (value, row, index) {
                    if(value==2){
                        return "<span class=\"label  badge  label-success\">已同意</span>";
                    }else if(value==0){
                        return "<span class=\"label  badge  label-danger\">已驳回</span>";
                    }else if(value==1) {
                        return "<span class=\"label  badge  label-default\">待审核</span>";
                    }
                }
            },
            { title: "审批人", field: 'name'},
            {
                title: "操作",
                width: '110',
                formatter: function (value, row, index) {
                    var actions = [];
                    if(row.verifier == row.loginUid && hasP('con:audit:view') && row.appStatus==1){

                        // actions.push('<a class="btn btn-success btn-xs" href="'+ ctx + 'contractManage/contractApprove?quoteId=' + row.fkId + '&conId=' + row.id + '&processId=' + row.processId + '" > 审核</a> ');
                        actions.push('<a class="btn btn-success btn-xs" href="'+ ctx + 'contractManage/contractApproveNew?quoteId=' + row.fkId + '&conId=' + row.id + '&processId=' + row.processId + '&parentId='+row.parentId+'" > 审核</a> ');
                    }else {

                        actions.push('<a class="btn btn-info btn-xs" href="'+ ctx + 'contractManage/contractApproveDetail?quoteId=' + row.fkId + '&conId=' + row.id + '&processId=' + row.processId + '&parentId='+row.parentId+'" > 查看</a> ');
                    }
                        // actions.push('<a class="btn btn-warning btn-xs" href="'+ ctx + 'quoteManage/viewQuotation/quoteId/'+ row.fkId+'"> 查看报价单</a> ');

                    return actions.join('');
                }
            }
        ]
    });
    /**
     * 表格搜索
     */
    $("#btn-search").click(function () {
        js.table.search(table);
    });

    /**
     * ,uid,logUid
     * 待审批记录的id
     * @param contid
     *
     * 审批人id
     * @param uid
     *
     * 当前登录人id
     * @param logUid
     */
    function submitApp(idd){
        // if(uid!=logUid){
        //     js.modal.alert("对不起，您没有审批权限！");
        //     return;
        // }
        js.post({
            url: ctx + "contractManage/contractAppInfoByUserRole",
            data:{"id":idd},
            success: function (result) {
                if (result.type === web_status.SUCCESS) {

                    js.modal.success(result.msg);
                    js.table.refresh(table);
                } else {
                    js.modal.warning(result.msg);
                }
                js.modal.closeLoading();
            }
        });
    }
</script>